package com.ziru.ziru.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author 缘友一世
 * date 2023/5/31-12:38
 * 配置swagger3的页面信息
 */
@EnableOpenApi
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .groupName("奋斗筑梦组")
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ziru.ziru.controller"))
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //标题
                .title("自如租房研发平台Api接口文档")
                //简介
                .description("奋斗筑梦队研发")
                //服务条款
                .termsOfServiceUrl("")

                //作者个人信息
                .contact(new Contact("奋斗筑梦","https://blog.csdn.net/yang2330648064?type=blog","2330648064@qq.com"))
                //版本
                .version("1.0").build();
    }
}
